<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
        <title>意见反馈</title>
        <link rel="stylesheet" href="<c:url value="/static/wx/css/style.css"/>" />
        <script type="text/javascript" src="<c:url value="/static/wx/js/lib/rem.js"/>"></script>
    </head>

    <body class="befeff4">
        <div id="wrap">
            <div class="suggestion_wrap">
                <div class="input_wrap">
                    <div>
                        <textarea placeholder="欢迎您提供宝贵的意见和建议" id="suggestion"></textarea>
                    </div>
                </div>
            </div>

            <div class="wrap_btn mt30">
                <a href="javascript:void(0)" class="button" id="submit_btn">提交</a>
            </div>
            <div class="msg-succ">
                <img src="<c:url value="/static/wx/img/succ_icon.png"/>" /> <span class="f20">提交成功</span> 
            </div>
        </div>
        <input type="hidden" id=userId value="${userId}" />
        <script type="text/javascript" src="<c:url value="/static/wx/js/lib/jquery-3.3.1.min.js"/>"></script>
        <script type="text/javascript">
            var userId = $("#userId").val();
            $(document).ready(function() {
                $("#submit_btn").on("click",function(){
                    
                    var suggestion = document.getElementById('suggestion').value;
                    if(!suggestion){
                        alert("内容不能为空");
                    }else{
                        var f = arguments.callee, self = this;
                        $(self).unbind('click', f);
                        $.ajax({
                            type:"post",
                            url: "<c:url value="/wx/opinionAdd.do"/>",
                            data: {
                            	content : suggestion,
                                userId : userId,
                            },
                            cache: true, 
                            async:false, 
                            dataType: "json",
                            success: function(data){
                                if (data.msg == "1") {
                                    $(".msg-succ").show();
                                    setTimeout(go, 2000);
                                    //返回我的页面
                                }else{
                                    $(self).click(f);
                                }
                            }
                        });
                    }
                })
            })
            
            function go() {
            	window.location.href="<c:url value="/wx/toMineHome.do"/>?id="+userId;
            }
        </script>
    </body>

</html>
